#!/usr/bin/env python
#coding: utf-8
'''
Created on 2017年4月17日

@author: Administrator
'''

from django.db.models import signals

from message.models import Message
from message.utils import data_cache

def user_message_changed_handler(sender, instance, **kwargs):
    u'''
    function - 删除用户未读消息数缓存
    sender: Message
    instance: object
    '''
    
    data_cache.delete_user_message_cache(instance.recv_user_id)

signals.post_save.connect(user_message_changed_handler, Message, dispatch_uid="message.message.post_save")
signals.post_delete.connect(user_message_changed_handler, Message, dispatch_uid="message.message.post_delete")
